<?php

class A extends CActiveRecord 
{
	
	
	public function scopes() {
		return array(
				'recently' => array(
						'order' => 'n DESC',
						'limit' => 2,
				)
		);
	}
	
	public function recently2($limit = 5)	{
		$this->getDbCriteria()->mergeWith(array(
				'order'=>'n DESC',
				'limit'=>$limit,
		));
		return $this;
	}
	
	public function relations()
	{
		return array(
				'b' => array(self::HAS_MANY, 'B', 'a_id'),
		);
	}
	
	
// 	public function defaultScope()
// 	{
// 		return array(
// 				//'condition' => "language='".Yii::app()->language."'",
// 				'condition' => "n > 1000",
// 		);
// 	}
	
	public function tableName()	{
		return 'tbl_a';
	}
	
	
	public static function model($className=__CLASS__) {
		return parent::model($className);
	}
	
} 